/*
n m k
a[n]
b[m]
c[k]

(a[i]*b[j])modc[t]
*/
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
using ll=long long;
#define mod(x, y, z) (1ll*(1ll*x*y%z+z)%z)
#define DEBUG
inline long long read()
{
    int c=getchar(), f=1; long long x=0;
    if(c=='-') f*=-1, c=getchar();
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    return f*x;
}
inline void write(long long x)
{
    if(x>=10) write(x/10);
    putchar(x%10+'0');
}

const int N=210;
int n, m, k, cnt;
int a[N], b[N], c[N];
ll ans;

void init()
{
    n=read(), m=read(), k=read();
    // for(int i=1; i<=n; i++) a[i]=read();
    // for(int i=1; i<=m; i++) b[i]=read();
    // for(int i=1; i<=k; i++) c[i]=read();

    for(int i=1; i<=n; i++) scanf("%d", &a[i]);
    for(int i=1; i<=m; i++) scanf("%d", &b[i]);
    for(int i=1; i<=k; i++) scanf("%d", &c[i]);

}

void solve()
{
    init();
    
    for(int i=1; i<=n; i++)  
        for(int j=1; j<=m; j++)      
            for(int x=1; x<=k; x++)
                ans=max(ans, mod(a[i], b[j], c[x]));
    write(ans); puts("");
}

signed main()
{

    #ifdef DEBUG
        freopen("../in.txt", "r", stdin);
        freopen("../out.txt", "w", stdout);
    #endif
    int T=1; //cin >> T; 
    while(T--) 
    {
        solve();
    }
    return 0;
}